//
//  CarsCell.m
//  掌上宏力
//
//  Created by admin on 2017/6/8.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "CarsCell.h"
#import "CarsModel.h"

@interface CarsCell ()

@property (nonatomic,weak) UILabel *driverLab;
@property (nonatomic,weak) UILabel *userLab;
@property (nonatomic,weak) UILabel *senderLab;
@property (nonatomic,weak) UILabel *numberLab;


@end

@implementation CarsCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        CGFloat height = 25;
        UILabel *numberL = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 200, height)];
        numberL.font = kFont(15);
        [self.contentView addSubview:numberL];
        self.numberLab = numberL;
        
        CGFloat margin = 20;
        CGFloat width = (kScreenW-50-margin)/3;
        
        CGFloat font = 14;
        UILabel *driverL = [[UILabel alloc] initWithFrame:CGRectMake(10, numberL.bottom, width, height)];
        driverL.font = kFont(font);
        [self.contentView addSubview:driverL];
        self.driverLab = driverL;
        
        UILabel *userL = [[UILabel alloc] initWithFrame:CGRectMake(driverL.right+margin, numberL.bottom, width, height)];
        userL.font = kFont(font);
        [self.contentView addSubview:userL];
        self.userLab = userL;
        
        UILabel *senderL = [[UILabel alloc] initWithFrame:CGRectMake(userL.right+margin, numberL.bottom, width, height)];
        senderL.font = kFont(font);
        [self.contentView addSubview:senderL];
        self.senderLab = senderL;
    }
    return self;
}
-(void)setCarsModel:(CarsModel *)carsModel{
    NSString *number = [NSString stringWithFormat:@"车牌号：%@",carsModel.number];
    self.numberLab.text = number;
    
    NSString *driver = [NSString stringWithFormat:@"司  机：%@",carsModel.driver];
    self.driverLab.text = driver;
    
    NSString *user = [NSString stringWithFormat:@"用车人：%@",carsModel.user];
    self.userLab.text = user;
    
    NSString *sender = [NSString stringWithFormat:@"派车人：%@",carsModel.sender];
    self.senderLab.text = sender;
}
+(instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *cellId = @"cellId";
    CarsCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (cell == nil) {
        cell = [[CarsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
